function checkLogin() {
	var sessionId= '${pageContext.session.id}';
	if( sessionId == null) {
		$(".before-login").addClass("hidden");
		$(".after-login").removeClass("hidden");
	}
	else {
		$(".after-login").addClass("hidden");
		$(".before-login").removeClass("hidden");
	}
}
$(function() {
	checkLogin();
	
	// ADD SLIDEDOWN ANIMATION TO DROPDOWN //
	$('.dropdown').on('show.bs.dropdown', function(e){
		$(this).find('.dropdown-menu').first().stop(true, true).slideDown();
	});

	// ADD SLIDEUP ANIMATION TO DROPDOWN //
	$('.dropdown').on('hide.bs.dropdown', function(e){
		$(this).find('.dropdown-menu').first().stop(true, true).slideUp();
	});
	
	$('form[data-async]').on('submit', function(event) {
		var $form = $(this);
		var $target = $($form.attr('data-target'));
		 
		$.ajax({
			type: $form.attr('method'),
			url: $form.attr('action'),
			data: $form.serialize(),
			 
			success: function(data, status) {
				$target.html(data);
			}
		});
		event.preventDefault();
	});
});

